
// 字符串中找出连续最长的数字串
#include <iostream>
#include <string>
using namespace std;

int main() {
    string str;
    string ret;
    cin >> str;
    for(int letf = 0, right = 0; right < str.size(); right++)
    {
        if(str[right] >= '0' && str[right] <= '9')
        {
            letf = right;
            while(right < str.size() && str[right] >= '0' && str[right] <= '9')
                ++right;
            if(right - letf + 1 > ret.size())
                ret = str.substr(letf, right - letf);
        }
    }
    cout << ret << endl;
    return 0;
}

// 岛屿数量
class Solution {
    public:
        int dx[4] = {0, 0, 1, -1};
        int dy[4] = {1, -1, 0, 0};
        bool vis[201][201] = {false};
        int m, n;
        int solve(vector<vector<char> >& grid) {
            m = grid.size(), n = grid[0].size();
            int ret = 0;
            for(int i = 0; i < m; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if(grid[i][j] == '1' && !vis[i][j])
                    {
                        ++ret;
                        bfs(grid, i, j);
                    }
                }
            }
            return ret;
        }
        void bfs(vector<vector<char> >& grid, int i , int j)
        {
            vis[i][j] = true;
            for(int k = 0; k < 4; k++)
            {
                int x = i + dx[k], y = j + dy[k];
                if(x >= 0 && x < m && y >= 0 && y < n && grid[x][y] == '1' && !vis[x][y])
                    bfs(grid, x, y);
            }
        }
    };

// 拼三角
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int arr[6];
    while(n--)
    {
        for(int i = 0; i < 6; i++)
            cin >> arr[i];
        sort(arr, arr+ 6);
        if((arr[0] + arr[1] > arr[2] && arr[3] + arr[4] > arr[5]) ||
            (arr[0] + arr[2] > arr[3] && arr[1] + arr[4] > arr[5]) ||
            (arr[0] + arr[3] > arr[4] && arr[1] + arr[2] > arr[5]) ||
            (arr[0] + arr[4] > arr[5] && arr[1] + arr[2] > arr[3])
          )
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

// 求最小公倍数
#include <iostream>
using namespace std;

int func(int a, int b)
{
    if(b == 0) return a;
    return func(b, a % b);
}

int main() {
    int a, b;
    cin >> a >> b;
    if(a < b)
        swap(a, b);

    cout << (a * b / func(a, b)) << endl;
    return 0;
}

// 数组中的最长连续子序列
class Solution {
    public:
        int MLS(vector<int>& arr) {
            sort(arr.begin(), arr.end());
            int n = arr.size();
            int ret = 0;
            for(int i = 0; i < n;)
            {
                int j = i + 1;
                int count = 1;
                while(j < n)
                {
                    if(arr[j] - arr[j - 1] == 1)
                    {
                        ++j;
                        ++count;
                    }
                    else if(arr[j] - arr[j - 1] == 0)
                        ++j;
                    else
                        break;
                }
                ret = max(ret, count);
                i = j;
            }
            return ret;
        }
    };


// 字母收集
#include <iostream>
#include <unordered_map>
using namespace std;

char arr[501][501];
int dp[501][501] = {0};

int main() {
    int m, n;
    cin >> m >> n;
    for(int i = 0; i < m; i++)
        for(int j = 0; j < n; j++)
            cin >> arr[i][j];
    
    unordered_map<char,int> hash({{'l', 4},
                                  {'o', 3},
                                  {'v', 2},
                                  {'e', 1}});

    for(int i = 1; i <= m; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + hash[arr[i - 1][j - 1]];
        }
    }
    cout << dp[m][n] << endl;
    return 0;
}